import js from '@eslint/js'
import globals from 'globals'
import tseslint from 'typescript-eslint'
import pluginVue from 'eslint-plugin-vue'
import pluginPrettier from 'eslint-plugin-prettier' // ✅ 引入 prettier 插件
import { defineConfig } from 'eslint/config'

export default defineConfig([
  {
    files: ['**/*.{js,mjs,cjs,ts,vue}'],
    plugins: {
      js,
      prettier: pluginPrettier // ✅ 注册 prettier 插件
    },
    extends: ['js/recommended', 'plugin:prettier/recommended'], // ✅ 启用 prettier 推荐规则
    rules: {
      'prettier/prettier': 'error' // ✅ 格式不符合 prettier 时，报错
    },
    languageOptions: {
      globals: globals.browser
    }
  },
  tseslint.configs.recommended,
  pluginVue.configs['flat/essential'],
  {
    files: ['**/*.vue'],
    languageOptions: {
      parserOptions: {
        parser: tseslint.parser
      }
    }
  }
])

